package com.xthh._function.MyPopWindow;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xt.xthh.R;

import java.util.List;

/**
 * Copyright: Copyright (c) 2017-2025
 * Company:
 *
 * @author: 赵小贱
 * @date: 2017/8/23
 * describe:
 */
public class HH_SpinerAdapter extends BaseAdapter {



    public static interface IOnItemSelectListener {
        public void onItemClick(int pos);
    }

    private List<String> mObjects;
    private LayoutInflater mInflater;
    private int select = 0;
    Context ctx;

    public HH_SpinerAdapter(Context context, List<String> mObjects, int sel) {
        this.mObjects = mObjects;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        select = sel;
        ctx = context;
    }





    @Override
    public int getCount() {

        return mObjects.size();
    }

    @Override
    public Object getItem(int pos) {
        return mObjects.get(pos).toString();
    }

    @Override
    public long getItemId(int pos) {
        return pos;
    }

    @Override
    public View getView(int pos, View convertView, ViewGroup arg2) {
        ViewHolder viewHolder;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.spiner_item_layout1, null);
            viewHolder = new ViewHolder();
            viewHolder.mTextView = (TextView) convertView.findViewById(R.id.textView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        //Object item =  getItem(pos);
        viewHolder.mTextView.setText(mObjects.get(pos));

        if (select == pos){
            viewHolder.mTextView.setBackground(ctx.getDrawable(R.drawable.bg_linearlayout_circle_3));
        } else {
            viewHolder.mTextView.setBackground(ctx.getDrawable(R.drawable.bkg_control_white));
        }

        return convertView;
    }


    public static class ViewHolder {
        public TextView mTextView;
    }

}